/**
 * Created by Wangwei on 2019-05-17 20:37.
 */

package config

import (
	"github.com/BurntSushi/toml"
	"io/ioutil"
)

var All config
var App *app

func InitConfig(cfgFile string) {
	confFile := FindConfFile("/application.toml")
	if cfgFile != "" {
		confFile = cfgFile
	}

	bytes, err := ioutil.ReadFile(confFile)
	if err != nil {
		panic(err)
	}

	if _, err := toml.Decode(string(bytes), &All); err != nil {
		panic(err)
	}

	App = All.App
}

// 完整配置
type config struct {
	App        *app           `toml:"app"`
}

// web应用
type app struct {
	GetSubdomainApi              string `toml:"get_subdomain_api"`
}
